Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tree: add missing div-by-zero error for float div #37774

Merged
merged 1 commit into from May 24, 2019

Conversation

jordanlewis
Copy link
Member

Previously, dividing a float by 0 would return -Inf, instead of
returning a divide by 0 error as expected.

Release note (bug fix): dividing floats by zero now returns an error,
instead of -Inf.

@jordanlewis jordanlewis requested review from maddyblue, rafiss and a team May 23, 2019 15:56
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Collaborator

@rafiss rafiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 of 2 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @jordanlewis and @mjibson)


pkg/sql/sem/tree/eval_test.go, line 255 at r1 (raw file):

		{`1 % 0`, `zero modulus`},
		{`1 / 0`, `division by zero`},
		{`1::float / 0::float`, `division by zero`},

why does the test go here instead of in testdata/eval/float_decimal_div? is it because it's an error?

Copy link
Member Author

@jordanlewis jordanlewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @mjibson and @rafiss)


pkg/sql/sem/tree/eval_test.go, line 255 at r1 (raw file):

Previously, rafiss (Rafi Shamim) wrote…

why does the test go here instead of in testdata/eval/float_decimal_div? is it because it's an error?

Yes, as far as I can tell, the datadriven package that we use for the eval tests here doesn't know how to expect errors yet. That would be a nice feature addition - for now, this other test has a good way of specifying expected errors.

Copy link
Member Author

@jordanlewis jordanlewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also had to remove 2 older tests that expected float div-by-0 to return non-errors.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @mjibson and @rafiss)

Copy link
Collaborator

@rafiss rafiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @mjibson)

pkg/sql/sem/tree/eval.go Outdated Show resolved Hide resolved
Previously, dividing a float by 0 would return -Inf, instead of
returning a divide by 0 error as expected.

Release note (bug fix): dividing floats by zero now returns an error,
instead of -Inf.
@jordanlewis
Copy link
Member Author

bors r+

TFTRs!

craig bot pushed a commit that referenced this pull request May 24, 2019
37774: tree: add missing div-by-zero error for float div r=jordanlewis a=jordanlewis

Previously, dividing a float by 0 would return -Inf, instead of
returning a divide by 0 error as expected.

Release note (bug fix): dividing floats by zero now returns an error,
instead of -Inf.

Co-authored-by: Jordan Lewis <jordanthelewis@gmail.com>
@craig
Copy link
Contributor

craig bot commented May 24, 2019

Build succeeded

@craig craig bot merged commit 9cdc5cf into cockroachdb:master May 24, 2019
@jordanlewis jordanlewis deleted the fix-div-float-0 branch May 24, 2019 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants